<template>
    <div class>
        <el-row>
            <el-row>
                <el-col :span="24"
                    class="content_title"
                    style="margin-top: 0px;padding-top:24px">
                    <el-col :span="12">
                        <HeadTitle></HeadTitle>
                    </el-col>
                    <el-col :span="12">
                    </el-col>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24"
                    class="account_box">
                    <el-form :inline="true"
                        class="demo-form-inline">
                        <el-col :span="8">
                            <el-form-item label="封停账号：">
                                <el-input v-model="close_account"
                                    style="width:400px"
                                    clearable
                                    size="small"
                                    placeholder="请输入要封停的用户名"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="1">
                            <el-form-item>
                                <el-button type="primary"
                                    size="small"
                                    @click="close">封停</el-button>
                            </el-form-item>
                        </el-col>
                    </el-form>
                </el-col>
                <el-col :span="24">
                    <el-form :inline="true"
                        class="demo-form-inline">
                        <el-col :span="8">
                            <el-form-item label="解封账号：">
                                <el-input v-model="open_account"
                                    style="width:400px"
                                    clearable
                                    size="small"
                                    placeholder="请输入要解封用户名"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="1">
                            <el-form-item>
                                <el-button type="primary"
                                    size="small"
                                    @click="open">解封</el-button>
                            </el-form-item>
                        </el-col>
                    </el-form>
                </el-col>
            </el-row>
        </el-row>
    </div>
</template>
<script>
import HeadTitle from "@/components/currency/HeadTitle.vue";
export default {
    name: "deal_account",
    data () {
        return {
            close_account: "",
            open_account: "",
        };
    },
    components: {
        HeadTitle
    },
    methods: {
        close () {
            this.$swal({
                title: `您确定要封停用户名${this.close_account}`,
                text: "封停后将无法操作，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "是的，我要封停",
                cancelButtonText: "容我三思"
            }).then(willDelete => {
                if (willDelete.value) {
                    var params = {};
                    params.username = this.close_account;
                    this.$api.getUser.close_account(params).then(res => {
                        if (res.data.code == 200) {
                            this.$swal("封号成功！", "您已经封停了该用户。", "success");
                            this.close_account = "";
                            this.open_account = "";
                        } else {
                            this.$swal("封号失败！", res.data.result, "success");
                        }
                    });
                }
            });
        },
        open () {
            this.$swal({
                title: `您确定要解封用户名${this.close_account}`,
                text: "请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "是的，我要解封",
                cancelButtonText: "容我三思"
            }).then(willDelete => {
                if (willDelete.value) {
                    var params = {};
                    params.username = this.open_account;
                    this.$api.getUser.open_account(params).then(res => {
                        if (res.data.code == 200) {
                            this.$swal("解封成功！", "您已经解封了该用户。", "success");
                            this.close_account = "";
                            this.open_account = "";
                        } else {
                            this.$swal("解封失败！", res.data.result, "success");
                        }
                    });
                }
            });
        }
    }
};
</script>
<style scoped>
.bg_write {
    height: 100%;
}
.account_box {
    margin-top: 50px;
}
</style>
